<template>
  <div class="container">
    <el-table
      :data="dataList"
      border
      style="width: 70%;margin:0 auto;margin-top:50px;">
      <el-table-column
        prop="createTime"
        header-align="center"
        align="center"
        width="200"
        label="创建时间">
      </el-table-column>
      <el-table-column
        prop="updateTime"
        header-align="center"
        align="center"
        label="更新时间">
      </el-table-column>
      <el-table-column
        prop="endTime"
        header-align="center"
        align="center"
        width="50"
        label="修正时间">
      </el-table-column>
      <el-table-column
        prop="thisNum"
        header-align="center"
        align="center"
        label="本条编号">
      </el-table-column>
      <el-table-column
        prop="ansPer"
        header-align="center"
        align="center"
        width="150"
        :show-overflow-tooltip="true"
        label="回复人">
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        align="center"
        label="目前状态">
      </el-table-column>
      <el-table-column
        prop="ip"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small">回复</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- bug列表 -->
    <el-row>
        <el-table 
            :data="modify" 
            highlight-current-row 
            layout="total, prev, pager, next"
            style="width: 100%;">
            <el-table-column prop="bugs_title" label="bug标题" width="120" sortable>
            </el-table-column>
            <el-table-column prop="bugs_description" label="bug描述" width="140" sortable>
            </el-table-column>
            <el-table-column prop="bugs_content" label="bug内容" width="140" sortable>
            </el-table-column>
            <el-table-column prop="bugs_createtime" label="bug创建时间" width="150" sortable>
            </el-table-column>
            <el-table-column prop="bugs_gettime" label="bug获取时间" width="150" sortable>
            </el-table-column>
            <el-table-column prop="bugs_updatetime" label="bug更新时间" width="180" sortable>
            </el-table-column>
            <el-table-column prop="bugs_endtime" label="bug修复时间" width="160" sortable>
            </el-table-column>
            <el-table-column prop="bugs_status" label="bug状态" min-width="180" :formatter="formatStatus" sortable>
            </el-table-column>
            <el-table-column prop="b_u_name" label="发起人" min-width="180" sortable>
            </el-table-column>
            <el-table-column prop="b_p_title" label="指定人" min-width="180" sortable>
            </el-table-column>
            <el-table-column prop="b_su_name" label="bug所属项目" min-width="180" sortable>
            </el-table-column>
            <el-table-column label="操作" width="220" fixed="right">
                <template scope="scope">
                    <el-button type="danger" size="small" @click="showDetail(scope.row)">查看</el-button>
                    <el-button type="danger" size="small" @click="handleDetail(scope.row)">完成</el-button>
                    <el-button type="danger" size="small" @click="showEdit(scope.row)">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!-- 分页 -->
        <el-pagination
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-size="pageSize"
        :total="total"
        layout="total, prev, pager, next">
        </el-pagination>
    </el-row>
    <el-button type="primary" class="btn" @click="back">
      返回
    </el-button>
    
  </div>
</template>

<script>
import axios from 'axios'

export default {
  props: {
    bugDetail: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      value: new Date(),
      value1: new Date(),
      textarea3: 0,
      dataList: [],
      modify: []
    }
  },
  props: {
    bugNum: {
      type: Number,
      default: 1
    }
  },
  created() {
    this._getDataList()
  },
  methods: {
    //返回操作
    back() {
      this.$router.back()
    },
    _getDataList() {
      const url = 'api/bugs/bugsInfo.html'
      const params = {
        bugs_id: this.$route.params.id
      }
      axios.post(url, params).then(res => {
        if (res.data) {
          console.log(res.data.data)
          this.dataList = this._dataToArray(res.data.data)
          console.log(this.dataList)
        }
      })
    },
    _dataToArray(obj) {
      let row = []
      let ret = {
        createTime: obj.bugs_createtime,
        updateTime: obj.bugs_updatetime,
        endTime: obj.bugs_endtime,
        thisNum: obj.bugs_id,
        ansPer: obj.b_su_name,
        status: obj.bugs_status
      }
      row.push(ret)
      return row
    }
  },

  computed: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return 'warning-row'
      } else if (rowIndex === 3) {
        return 'success-row'
      }
      return ''
    }
  }
}
</script>
<style lang="stylus" scoped rel="stylesheet/stylus">
.container
    padding 80px
    text-align center
    .steps
        padding-top 100px
    .btn
        position absolute
        left 40px
        top 80px
</style>
